package com.qtcm.nas.wzh.dingdan.controller;


import com.qtcm.nas.wzh.commoditys.pojo.Commodity;
import com.qtcm.nas.wzh.dingdan.pojo.Orders;
import com.qtcm.nas.wzh.dingdan.service.IOrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


@Controller("ordersCroller")
@RequestMapping("/ordersC")
public class OrdersCroller {
    @Autowired
    @Qualifier("ordersService")
    private IOrdersService ordersService;

    @RequestMapping("/findAlll")
    public String findAll(Model model) {
        List<Orders> alll = ordersService.findAlll();
        model.addAttribute("list",alll);
        return "order_List";
    }
    //订单详情
    @RequestMapping("/dingdan")
    public String findbyshangpin(Model model,int D_Comment_number){
        List<Orders> a =ordersService.findbyshangpin( D_Comment_number);
        model.addAttribute("list",a);
        return "order_Detail";
    }
    //编辑订单跳转方法
    @RequestMapping("/updatebyid")
    public String updatebyid(Model model,int D_Comment_number) {
        List<Orders> a = ordersService.updatebyid(D_Comment_number);
        System.out.println(a);
        model.addAttribute("list", a);
        return "order_edit";
    }
    @RequestMapping("/deletebyid")
    public String deletebyid(int D_Comment_number) {
        System.out.println("id为"+D_Comment_number);
        Orders o=new Orders();
        System.out.println(o);
        ordersService.deletebyid(D_Comment_number);
        System.out.println(o);
        return "forward:order_edit";
    }

}